package com.fone.player.entity;

import java.util.Arrays;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * 缓存视频播放时使用
 * 
 * @author kongxiaojun
 * @since 2014-6-9
 */
public class CacheVideo implements Parcelable {

	/**
	 * 名称
	 */
	private String name;
	/**
	 * url
	 */
	private String[] urls;
	/**
	 * 持续时间
	 */
	private int[] durations;
	/** xyzplay 播放地址 */
	private String xyzplay;
	/** 图片地址 */
	private String pic;
	/** 是否缓存完成*/
	private boolean downFinish;

	public CacheVideo() {
		super();
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(name);
		dest.writeInt(urls.length);
		dest.writeStringArray(urls);
		dest.writeInt(durations.length);
		dest.writeIntArray(durations);
		dest.writeString(xyzplay);
		dest.writeString(pic);
		dest.writeInt(downFinish ? 1 : 0);
	}

	public static final Parcelable.Creator<CacheVideo> CREATOR = new Parcelable.Creator<CacheVideo>() {
		public CacheVideo createFromParcel(Parcel in) {
			return new CacheVideo(in);
		}

		public CacheVideo[] newArray(int size) {
			return new CacheVideo[size];
		}
	};

	private CacheVideo(Parcel in) {
		name = in.readString();
		int length = in.readInt();
		urls = new String[length];
		in.readStringArray(urls);
		length = in.readInt();
		durations = new int[length];
		in.readIntArray(durations);
		xyzplay = in.readString();
		pic = in.readString();
		downFinish = in.readInt() == 0 ? false : true;
	}

	public CacheVideo(String name, String xyzPlay, String picUrl) {
		this.name = name;
		xyzplay = xyzPlay;
		pic = picUrl;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {

		this.name = name;
	}

	public String[] getUrls() {
		return urls;
	}

	public void setUrls(String[] urls) {

		this.urls = urls;
	}

	public int[] getDurations() {
		return durations;
	}

	public void setDurations(int[] durations) {
		this.durations = durations;
	}

	public String getXyzplay() {
		return xyzplay;
	}

	public void setXyzplay(String xyzplay) {

		this.xyzplay = xyzplay;
	}

	public String getPic() {
		return pic;
	}

	public void setPic(String pic) {

		this.pic = pic;
	}
	
	public boolean isDownFinish() {
		return downFinish;
	}

	public void setDownFinish(boolean downFinish) {
		this.downFinish = downFinish;
	}

	@Override
	public String toString() {
		return "CacheVideo [name=" + name + ", urls=" + Arrays.toString(urls) + ", durations=" + Arrays.toString(durations) + ", xyzplay=" + xyzplay + ", pic=" + pic + "]";
	}

}
